<extend name="Public/head" /> 
<block name="headbar">
    <header class="aui-bar">
            <a class="aui-btn aui-btn-info aui-pull-left"  onclick="goback()">
                <span class="aui-iconfont aui-icon-left"></span>
            </a>
            <a href="javascript:;" class="aui-btn aui-pull-right aui-bar-info openurl" data-url="register"><span class="iconfont">&#xe604;</span></a>
            <div class="title">{$title}</div>
        </header>
</block>
<block name="body">
	<div class="aui-content">
        <form class="ajax-post" method = 'post' action="login" onsubmit="return validator(this)">
        <div class="aui-form">
            <div class="aui-input-row">
                <i class="aui-input-addon  aui-iconfont aui-icon-people"></i>
                <input type="text" class="aui-input" name="username" value="15179168911" placeholder="username"/>
            </div>
            <div class="aui-input-row">
           		 <i class="aui-input-addon  aui-iconfont aui-icon-lock"></i>
                 <input type="password" name="password" class="aui-input" value="000000" placeholder="password"/>
            </div>
            <div class="aui-btn-row aui-clearfix ">
                <button type="submit" class="aui-btn aui-btn-success aui-col-xs-12">确认</button>
            </div>
        </div>
        </form>
    </div>
</block>
<block name="script">
    <script>
        function validator(obj){
            var utest = /^1[3|5|7|8]\d{9}$/i;
            var ptest = /\w{6,}$/i;
            var username = $('input[name=username]').val();
            var pswd = $('input[name=password]').val();
            if(!utest.test(username))
            {  
                msg("请输入正确的用户名");
                return false ;
            }
            if(!ptest.test(pswd))
            {
                msg("请输入正确格式的密码");
                return false ;
            }
            post(API + 'login' , {username:username,password:pswd},function(data){
                 console.log(data);
                if(data.status)
                {   
                    msg(data.info);
                    setTimeout(function(){
                        window.location.href = data.url ; 
                    },1000);
                } else {
                    msg(data.info);
                }
            });
            return false ;
        }
    </script>
</block>